use SSODemo;

--region Drop Existing Procedures

IF OBJECT_ID(N'[usp_InsertSetting]') IS NOT NULL
	DROP PROCEDURE [usp_InsertSetting]

IF OBJECT_ID(N'[usp_SelectSetting]') IS NOT NULL
	DROP PROCEDURE [usp_SelectSetting]
	
IF OBJECT_ID(N'[usp_SelectTop1SettingByDateCreated]') IS NOT NULL
	DROP PROCEDURE [usp_SelectTop1SettingByDateCreated]

--endregion

GO

--region [usp_InsertSetting]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_InsertSetting]
-- Date Generated: 2009-05-28
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_InsertSetting]
	@RegisterCheck bit,
	@PageSize int,
	@Copyright varchar(255),
	@DateCreated datetime,
	@ID uniqueidentifier OUTPUT
AS

SET NOCOUNT ON

INSERT INTO [Settings] (
	[ID],
	[RegisterCheck],
	[PageSize],
	[Copyright],
	[DateCreated]
) VALUES (
	@ID,
	@RegisterCheck,
	@PageSize,
	@Copyright,
	@DateCreated
)

--endregion

GO

--region [usp_SelectSetting]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_SelectSetting]
-- Date Generated: 2009-05-28
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_SelectSetting]
	@ID uniqueidentifier
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	[ID],
	[RegisterCheck],
	[PageSize],
	[Copyright],
	[DateCreated]
FROM
	[Settings]
WHERE
	[ID] = @ID

--endregion

GO

--region [usp_SelectTop1SettingByDateCreated]

------------------------------------------------------------------------------------------------------------------------
-- Generated By:   Zyg
-- Procedure Name: [usp_SelectTop1SettingByDateCreated]
-- Date Generated: 2009-05-28
------------------------------------------------------------------------------------------------------------------------

CREATE PROCEDURE [usp_SelectTop1SettingByDateCreated]
AS

SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ COMMITTED

SELECT
	TOP 1
	[ID],
	[RegisterCheck],
	[PageSize],
	[Copyright],
	[DateCreated]
FROM
	[Settings]
ORDER BY [DateCreated] DESC

--endregion

GO